package com.hot.service.impl;

import com.hot.mapper.HoteventsMapper;
import com.hot.pojo.Hotevents;
import com.hot.service.HoteventsService;
import com.hot.utils.PageUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Title
 * @Author 寻冬忆敏
 * @Date 2022/4/30 21:20
 * @Description
 */
@Service
public class HoteventsServiceImpl implements HoteventsService {

    @Resource
    private HoteventsMapper hoteventsMapper;

    @Override
    public PageUtil<Hotevents> getHoteventsPageList(Integer pageIndex, Integer pageSize, String keyWord) {
        int totalCount = hoteventsMapper.getHoteventsCount(keyWord);
        int totalPageCount = totalCount % pageSize == 0 ? totalCount / pageSize : totalCount / pageSize + 1;
        int strat = (pageIndex - 1) * pageSize;
        List<Hotevents> hoteventsSelect = hoteventsMapper.getHoteventsSelect(strat, pageSize, keyWord);
        PageUtil<Hotevents> pageUtil = new PageUtil<>();
        pageUtil.setPageIndex(pageIndex);
        pageUtil.setPageSize(pageSize);
        pageUtil.setData(hoteventsSelect);
        pageUtil.setTotalPageCount(totalPageCount);
        pageUtil.setTotalCount(totalCount);
        return null;
    }
}
